import 'dart:async';

import 'package:ebuy/dio/dio_helper/app_dio_config.dart';
import 'package:ebuy/dio/dio_helper/dio_helper.dart';
import 'package:ebuy/dio/dio_helper/s_dio_interceptor.dart';
import 'package:ebuy/controller.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:pretty_dio_logger/pretty_dio_logger.dart';

import 'home.dart';
import 'login.dart';

void main() async {
  await DioHelper().init(SDioBaseConfig());
  DioHelper().addInterceptors( iterable: [
    SDioInterceptor(),
    PrettyDioLogger(
      requestHeader: true,
      requestBody: true,
      responseBody: true,
    )
  ]);
  Get.put(CartController());
  runApp(GetMaterialApp(
    home: MyApp(),
  ));
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  navigatePage() {
    // Navigator.of(context).pushReplacement(new MaterialPageRoute(builder: (context) => Login()));
    Navigator.of(context).pushReplacement(new MaterialPageRoute(builder: (context) => Home()));
  }

  splashMove() {
    return Timer(Duration(seconds: 4), navigatePage);
  }

  @override
  void initState() {
    super.initState();
    splashMove();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      resizeToAvoidBottomInset: false,
      body: Container(
          color: Colors.white,
          child: Center(
            child: Image(
              image: AssetImage("images/ic_logo.png"),
              height: 140,
              width: 140,
            ),
          )),
    );
  }
}
